package com.self.gateway.controller;

import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.GatewayApiDefinitionManager;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

/**
 * @version v1.0
 * @ClassName: GatewayFlowRuleController
 * @Description:
 * @Author: Mac
 * @Date: 2022/5/22 18:05
 */
@RestController
public class GatewayFlowRuleController {

    /**
     * @Title: 获取网关流控规则
     */
    @GetMapping("/gw/flow/rules")
    public Set<GatewayFlowRule> getGatewayFlowRules(){
        return GatewayRuleManager.getRules();
    }

    /**
     * @Title: 获取api组流控规则
     */
    @GetMapping("/gw/api-group/rules")
    public Set<ApiDefinition> getApiGroupRules(){
        return GatewayApiDefinitionManager.getApiDefinitions();
    }
}
